package com.fr.web;

import com.fr.base.FRContext;
import com.fr.base.xml.BaseXMLUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.data.TableData;
import com.fr.report.PageSetChain;
import com.fr.report.ParameterReport;
import com.fr.report.RWorkBook;
import com.fr.report.Report;
import com.fr.report.ReportParameterAttr;
import com.fr.report.ReportWebAttr;
import com.fr.report.ResultWorkBook;
import com.fr.report.TemplateReport;
import com.fr.report.TemplateWorkBook;
import com.fr.report.io.ReportExportAttr;
import com.fr.report.io.TemplateImporter;
import com.fr.report.parameter.AbstractParameterUI;
import com.fr.report.parameter.CustomParameterUI;
import com.fr.report.parameter.Parameter;
import com.fr.report.script.Calculator;
import com.fr.schedule.ViewScheduleSavedInfo;
import com.fr.schedule.util.ScheduleUtils;
import java.io.File;
import java.io.FileInputStream;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

public class ScheduleWorkBook extends AbstractParameterUI
  implements TemplateWorkBook
{
  private static final long serialVersionUID = 1L;
  public static String TASKPARAMETERNAME = "task";
  public static String TIMEPARAMETERNAME = "triggerTime";
  public static String FILENAME = "fileName";
  private ReportParameterAttr rpa = null;
  private String actionName;
  private String taskName;
  private RWorkBook workBook;

  public ScheduleWorkBook(Map paramMap)
  {
    initParameterUI(paramMap);
  }

  public void initParameterUI(Map paramMap)
  {
    if ((paramMap.get("task") == null) || ((paramMap.get("task") != null) && (paramMap.get("triggerTime") != null)))
      return;
    this.taskName = ((String)paramMap.get("task"));
    this.rpa = new ReportParameterAttr();
    this.rpa.setShowWindow(true);
    this.rpa.setParameterUI(this);
  }

  public ParameterReport getParameterForm()
  {
    CustomParameterUI localCustomParameterUI = new CustomParameterUI();
    Parameter[] arrayOfParameter = ScheduleUtils.generatorParameters4Task(this.taskName);
    return CustomParameterUI.createDefaultParameterForm(arrayOfParameter, ScheduleUtils.generatorWidgetMap(arrayOfParameter, this.taskName), null);
  }

  public ResultWorkBook execute(Map paramMap)
  {
    if (paramMap.get("triggerTime") == null)
      return (this.workBook = new RWorkBook());
    File localFile1 = ScheduleUtils.getScheduleSavaPathFile(paramMap);
    if ((localFile1.exists()) && (localFile1.isDirectory()))
    {
      RWorkBook localRWorkBook = null;
      String str = null;
      if (paramMap.get("fileName") != null)
      {
        str = paramMap.get(FILENAME).toString();
      }
      else
      {
        localFile2 = new File(localFile1, "info.xml");
        if (!(localFile2.exists()))
          return null;
        ViewScheduleSavedInfo localViewScheduleSavedInfo = new ViewScheduleSavedInfo();
        try
        {
          localViewScheduleSavedInfo = (ViewScheduleSavedInfo)BaseXMLUtils.readXMLFile(new FileInputStream(localFile2), localViewScheduleSavedInfo);
        }
        catch (Exception localException2)
        {
          localException2.printStackTrace();
        }
        str = localViewScheduleSavedInfo.getTemplateFileName(ScheduleUtils.getParaMap(paramMap));
      }
      File localFile2 = new File(localFile1, str);
      if (localFile2.exists())
        try
        {
          localRWorkBook = new TemplateImporter().generateResult(localFile2);
        }
        catch (Exception localException1)
        {
          FRContext.getLogger().log(Level.WARNING, localException1.getMessage(), localException1);
        }
      this.workBook = localRWorkBook;
    }
    return this.workBook;
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    ScheduleWorkBook localScheduleWorkBook = (ScheduleWorkBook)super.clone();
    return localScheduleWorkBook;
  }

  public ResultWorkBook execute4Write(Map paramMap)
  {
    throw new UnsupportedOperationException();
  }

  public ResultWorkBook execute4Form(Map paramMap)
  {
    throw new UnsupportedOperationException();
  }

  public PageSetChain generateReportPageSet(List paramList)
  {
    throw new UnsupportedOperationException();
  }

  public ReportParameterAttr getReportParameterAttr()
  {
    return this.rpa;
  }

  public void setReportParameterAttr(ReportParameterAttr paramReportParameterAttr)
  {
    this.rpa = paramReportParameterAttr;
  }

  public void addReport(TemplateReport paramTemplateReport)
  {
    throw new UnsupportedOperationException();
  }

  public void addReport(String paramString, TemplateReport paramTemplateReport)
  {
    throw new UnsupportedOperationException();
  }

  public void clearAllTableData()
  {
    throw new UnsupportedOperationException();
  }

  public Report getReport(int paramInt)
  {
    if (this.workBook == null)
      throw new UnsupportedOperationException();
    return this.workBook.getReport(paramInt);
  }

  public int getReportCount()
  {
    if (this.workBook == null)
      return 0;
    return this.workBook.getReportCount();
  }

  public int getReportIndex(TemplateReport paramTemplateReport)
  {
    throw new UnsupportedOperationException();
  }

  public String getReportName(int paramInt)
  {
    throw new UnsupportedOperationException();
  }

  public ReportWebAttr getReportWebAttr()
  {
    return null;
  }

  public TableData getTableData(String paramString)
  {
    throw new UnsupportedOperationException();
  }

  public Iterator getTableDataNameIterator()
  {
    throw new UnsupportedOperationException();
  }

  public void putTableData(String paramString, TableData paramTableData)
  {
    throw new UnsupportedOperationException();
  }

  public void removeReport(String paramString)
  {
    throw new UnsupportedOperationException();
  }

  public void removeReport(int paramInt)
  {
    throw new UnsupportedOperationException();
  }

  public void removeReports()
  {
    throw new UnsupportedOperationException();
  }

  public void removeTableData(String paramString)
  {
    throw new UnsupportedOperationException();
  }

  public boolean renameTableData(String paramString1, String paramString2)
  {
    throw new UnsupportedOperationException();
  }

  public void setReport(int paramInt, TemplateReport paramTemplateReport)
  {
    throw new UnsupportedOperationException();
  }

  public void setReport(int paramInt, String paramString, TemplateReport paramTemplateReport)
  {
    throw new UnsupportedOperationException();
  }

  public void setReportName(int paramInt, String paramString)
  {
    throw new UnsupportedOperationException();
  }

  public void setReportWebAttr(ReportWebAttr paramReportWebAttr)
  {
    throw new UnsupportedOperationException();
  }

  public Calculator prepare4Recalculate(Map paramMap)
  {
    throw new UnsupportedOperationException();
  }

  public void recalculate(Calculator paramCalculator)
  {
    throw new UnsupportedOperationException();
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    throw new UnsupportedOperationException();
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    throw new UnsupportedOperationException();
  }

  public ReportExportAttr getReportExportAttr()
  {
    return null;
  }

  public void setReportExportAttr(ReportExportAttr paramReportExportAttr)
  {
    throw new UnsupportedOperationException();
  }

  public void apply4Parameters(Map paramMap)
  {
  }

  public Parameter[] getParameters()
  {
    return null;
  }

  public TemplateReport getTemplateReport(int paramInt)
  {
    throw new UnsupportedOperationException();
  }
}